home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
414_01
/
comm4.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-15
|
46KB
|
1,667 lines
/***********************************************************************/
/* COMM4.C - Commands P-S */
/* This file contains all commands that can be assigned to function */
/* keys or typed on the command line. */
/***********************************************************************/
/*
* THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
* Copyright (C) 1991-1993 Mark Hessling
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to:
*
* The Free Software Foundation, Inc.
* 675 Mass Ave,
* Cambridge, MA 02139 USA.
*
*
* If you make modifications to this software that you feel increases
* it usefulness for the rest of the community, please email the
* changes, enhancements, bug fixes as well as any and all ideas to me.
* This software is going to be maintained and enhanced as deemed
* necessary by the community.
*
* Mark Hessling email: M.Hessling@gu.edu.au
* 36 David Road Phone: +61 7 849 7731
* Holland Park Fax: +61 7 875 5314
* QLD 4121
* Australia
*/
/*
$Header: C:\THE\RCS\comm4.c 1.4 1993/09/01 16:25:43 MH Interim MH $
*/
#include <stdio.h>
#include "the.h"
#include "proto.h"
#ifdef UNIX
#include <signal.h>
#endif
/*#define DEBUG 1*/
/*-------------------------- external data ----------------------------*/
extern VIEW_DETAILS *vd_current,*vd_first,*vd_mark;
extern char current_screen;
extern SCREEN_DETAILS screen[MAX_SCREENS]; /* screen structures */
extern char display_screens; /* number of screens */
extern char number_of_views; /* number of open files */
extern bool horizontal;
extern char current_file; /* pointer to current file */
extern WINDOW *foot,*error_window,*divider;
extern bool error_on_screen;
extern char *rec;
extern unsigned short rec_len;
extern char *cmd_rec;
extern unsigned short cmd_rec_len;
extern char *pre_rec;
extern unsigned short pre_rec_len;
extern char *tempfilename;
extern char *temp_cmd;
extern char dir_filename[10];
extern char dir_pathname[MAX_FILE_NAME+1];
extern char curr_path[MAX_FILE_NAME+1] ;
extern char sp_path[MAX_FILE_NAME+1] ;
extern char sp_fname[MAX_FILE_NAME+1] ;
extern char dir_path[MAX_FILE_NAME+1] ; /* for dir and ls commands */
extern short save_coord_x[VIEW_WINDOWS];
extern short save_coord_y[VIEW_WINDOWS];
/*man-start*********************************************************************
COMMAND
print - send text to default printer or print spooler
SYNTAX
PRint [target] [n]
PRint LINE [text]
PRint STRING [text]
PRint FORMfeed
PRint CLOSE
DESCRIPTION
The PRINT command writes a portion of the current file to the default
printer or print spooler, or text entered on the command line.
PRINT [target] [n]
Sends text from the file contents up to the target to the printer
followed by a CR/LF (DOS) or LF(UNIX) after each line.
When [n] is specified, this sends a formfeed after [n] successive
lines of text.
PRINT LINE [text]
Sends the remainder of the text on the command line to the printer
followed by a CR/LF (DOS) or LF(UNIX).
PRINT STRING [text]
Sends the remainder of the text on the command line to the printer
without any trailing line terminator.
PRINT FORMFEED
Sends a formfeed (^L) character to the printer.
PRINT CLOSE
Closes the printer spooler.
COMPATIBILITY
XEDIT: N/A
KEDIT: Compatible.
SEE ALSO
printer
STATUS
Incomplete. OS/2 version does not work.
**man-end**********************************************************************/
#ifdef PROTO
int Print(char *params)
#else
int Print(params)
char *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
#define PRT_PARAMS 2
char *word[PRT_PARAMS+1];
unsigned short num_params;
long num_lines;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("comm4.c: Print");
#endif
num_params = param_split(params,word,PRT_PARAMS,WORD_DELIMS,TEMP_PARAM);
if (num_params == 0)
{
num_params = 1;
word[0] = (char *)"1";
}
post_process_line(CURRENT_VIEW->focus_line);
if (equal((char *)"line",word[0],4))
print_line(NO,0L,0,(char *)word[1],
(char *)"\r\n",FALSE);
else
if (equal((char *)"string",word[0],5))
print_line(NO,0L,0,(char *)word[1],(char *)"",FALSE);
else
if (equal((char *)"formfeed",word[0],4))
{
if (num_params > 1)
{
display_error(1,word[1]);
#ifdef TRACE
trace_return();
#endif
return(RC_INVALID_OPERAND);
}
print_line(NO,0L,0,(char *)"",(char *)"\f",FALSE);
}
else
if (equal((char *)"close",word[0],5))
{
if (num_params > 1)
{
display_error(1,word[1]);
#ifdef TRACE
trace_return();
#endif
return(RC_INVALID_OPERAND);
}
print_line(YES,0L,0,(char *)"",(char *)"",FALSE);
}
else
{
if ((num_lines = valid_target(word[0],get_true_line())) == TARGET_ERROR)
{
display_error(4,word[0]);
#ifdef TRACE
trace_return();
#endif
return(RC_INVALID_OPERAND);
}
if (num_params < 2)
word[1] = (char *)"0";
if (valid_positive_integer(word[1]) == NO)
{
display_error(4,word[0]);
#ifdef TRACE
trace_return();
#endif
return(RC_INVALID_OPERAND);
}
print_line(NO,num_lines,atoi(word[1]),(char *)"",
(char *)"\r\n",
(equal((char *)"all",word[0],3) ? TRUE : FALSE));
}
#ifdef TRACE
trace_return();
#endif
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
put - write part of a file to another
SYNTAX
PUT [target] [fileid]
DESCRIPTION
The PUT command writes a portion of the current file to another
file, either explicit or temporary.
When no fileid is supplied the temporary file is overwritten.
When a fileid is supplied the portion of the file written out
is appended to the specified file.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
putd,get
STATUS
Complete.
**man-end**********************************************************************/
#ifdef PROTO
int Put(char *params)
#else
int Put(params)
char *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
int rc;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("comm4.c: Put");
#endif
rc = execute_put(params,FALSE);
#ifdef TRACE
trace_return();
#endif
return(rc);
}
/*man-start*********************************************************************
COMMAND
putd - write part of a file to another and delete
SYNTAX
PUTD [target] [fileid]
DESCRIPTION
The PUTD command writes a portion of the current file to another
file, either explicit or temporary and deletes those lines written.
When no fileid is supplied the t